package sport.media;

import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.control.VolumeControl;

public class MMAPISampledBell implements IBell {
    private static Player w = null;
    private static Player r = null;
    private static Player e = null;
    
    MMAPISampledBell()
    {
        try {
            w = Manager.createPlayer(getClass().getResourceAsStream("/1b.mp3"),"audio/mpeg");
            w.realize();
            w.prefetch();
            ((VolumeControl)w.getControl("VolumeControl")).setLevel(100);
            r = Manager.createPlayer(getClass().getResourceAsStream("/2b.mp3"),"audio/mpeg");
            r.realize();
            r.prefetch();
            ((VolumeControl)r.getControl("VolumeControl")).setLevel(100);
            e = Manager.createPlayer(getClass().getResourceAsStream("/3b.mp3"),"audio/mpeg");
            e.realize();
            e.prefetch();
            ((VolumeControl)e.getControl("VolumeControl")).setLevel(100);
            //w.setLoopCount(5);
        } 
        catch (Exception e) { e.printStackTrace();} 
    }
    
    public void ringsStart() {
        try {
            w.stop();
            w.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }

    public void ringsRest() {
        try {
            r.stop();            
            r.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }

    public void ringsEnd() {
        try {
            e.stop();
            e.start();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
    }

}
